import sun.security.util.Length;

import java.util.Scanner;
import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 三石
 * Date: 2022-10-07
 * Time: 21:46
 */
public class LeetcodeWokr {
    /**
     *
     */
    //字典序排序
    static boolean dictionary(String[] arr){
        for (int i = 0; i < arr.length-1; i++) {
            for (int k = 0; k < arr[i].length(); k++) {
                if (arr[i].charAt(k)<arr[i+1].charAt(k)){
                    return true;
                }else if (arr[i].charAt(k)>arr[i+1].charAt(k)){
                    return false;
                }

            }
        }
        return true;
    }
    //长度排序
    static boolean Length(String[] arr){
        for (int i = 0; i < arr.length-1; i++) {
            for (int k = 0; k < arr[i].length(); k++) {
                if (arr[i].length()<=arr[i+1].length()){
                    return true;
                }else if (arr[i].charAt(k)>arr[i+1].charAt(k)){
                    return false;
                }

            }
        }
        return true;
    }
    public static void main33(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        String[] arr = new String[n];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = in.nextLine();
        }
        boolean ret1= Length(arr);
        boolean ret2=dictionary(arr);
        if (ret1==false && ret2==true){
            System.out.println("dictionary");
        }else if (ret1==true && ret2==false){
            System.out.println("Length");
        }else if(ret1==true && ret2==true){
            System.out.println("both");
        }else {
            System.out.println("none");
        }
    }



    /**
     * 回文个数
     */
    //判断是不是回文
    boolean isPalindrome(String str){
        int left=0;
        int right=str.length()-1;
        while (left<right){
            if(str.charAt(left)!=str.charAt(right)){
                return false;
            }
            left++;
            right--;
        }
        return true;
    }
    StringBuilder in=new StringBuilder();

    //插入
    void inNumber(String str, char b, int i){
        String str1= str+" ";
        for (int j = str1.length()-1; j>= i; j--) {
            char x=str1.charAt(j);
            char y=str1.charAt(j-1);
            x=y;
        }
        char m=str1.charAt(i);
        m=b;
    }
    /**
     *  // 合并两个有序顺序表
     */
    class Solution {
        public void merge(int[] nums1, int m, int[] nums2, int n) {
            int j=0;
            for (int i = m; i < m+n; ++i) { //把nums2 的所有数据插入到 nums1的后面去
                nums1[i] = nums2[j];
                j++;
            }
            Arrays.sort(nums1); //调用排序方法
        }
    }
    /**
     * 删除重复元素，使得元素只出现1次（如2，2 变成2）
     */
    //class Solution {
        public int removeDuplicates(int[] nums) {
            int n=nums.length;
            if(n==0){ //数组长度为0
                return 0;
            }
            int fast=1;
            int slow=1;
            while(fast<n){
                if(nums[fast]==nums[fast-1]){
                    fast++; //如果前后两个相等，只需要fast+1即可
                }else{
                    //如果前后两个不相等，把slow的值改成fast所指向的值，同时两个指针同时加1
                    nums[slow]=nums[fast];
                    fast++;
                    slow++;
                }
            }
            return slow;
        }
}
